import os


def mount_d(orin, data_name, ip):

    """
    发现硬盘后挂载
    """

    tdin, disk_path, stderr = orin.exec_command("sudo find /dev -name sda1")
    d_path = disk_path.read().decode("utf-8")

    mount = "ln -s {1} /data/{0}/val-launcher/tools/{0}/ && echo ok".format(data_name, d_path)

    if not stderr.read().decode("utf-8"):
        # 成功挂载
        a, b, c = orin.exec_command(
            "sudo mkdir -p /data/{0}/val-launcher/tools/{0}".format(
                data_name,
            )
        )

        a, b, c = orin.exec_command("sh mount.sh")
        # os.system("ssh root@{0} '{1}'".format(ip, mount))
        print(b.read().decode("utf-8"))

        # # 挂载命令
        # tdin, a, b = orin.exec_command(
        #     "sudo ln -s %s %s" % (
        #         disk_path.read().decode("utf-8"),
        #         "/data/{0}/val-launcher/tools/{0}".format(data_name),
        #     )
        # )

        print(c.read().decode("utf-8"))
